package org.fisco.bcos.asset.contract;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Event;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Int256;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple1;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple3;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.eventsub.EventCallback;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class Finance extends Contract {
    public static final String[] BINARY_ARRAY = {"60806040523480156200001157600080fd5b506200002b62000038640100000000026401000000009004565b60008081905550620001b9565b600061100190508073ffffffffffffffffffffffffffffffffffffffff166356004b6a6040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018060200180602001848103845260098152602001807f745f66696e616e63650000000000000000000000000000000000000000000000815250602001848103835260028152602001807f69640000000000000000000000000000000000000000000000000000000000008152506020018481038252602a8152602001807f66696e616e6365725f6163636f756e742c2066696e616e6365655f6163636f7581526020017f6e742c20616d6f756e74000000000000000000000000000000000000000000008152506040019350505050602060405180830381600087803b1580156200017857600080fd5b505af11580156200018d573d6000803e3d6000fd5b505050506040513d6020811015620001a457600080fd5b81019080805190602001909291905050505050565b61212680620001c96000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f5c0e2f214610051578063fcd7e3c11461011e575b600080fd5b34801561005d57600080fd5b50610108600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001909291905050506101a2565b6040518082815260200191505060405180910390f35b34801561012a57600080fd5b50610185600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611860565b604051808381526020018281526020019250505060405180910390f35b60008060008060008060008060008060008099506000985060009750600096506102006040805190810160405280600481526020017f42616e6b00000000000000000000000000000000000000000000000000000000815250611860565b809950819a505050600089141515610322577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b838110156102dd5780820151818401526020810190506102c2565b50505050905090810190601f16801561030a5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b61032b8d611860565b809850819a50505060008914151561044d577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe99507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b838110156104085780820151818401526020810190506103ed565b50505050905090810190601f1680156104355780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b8b881015610565577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd99507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015610520578082015181840152602081019050610505565b50505050905090810190601f16801561054d5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b868c8801101561067f577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc99507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b8381101561063a57808201518184015260208101905061061f565b50505050905090810190601f1680156106675780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b6106896000611ccc565b95508573ffffffffffffffffffffffffffffffffffffffff166313db93466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156106ef57600080fd5b505af1158015610703573d6000803e3d6000fd5b505050506040513d602081101561071957600080fd5b810190808051906020019092919050505094508473ffffffffffffffffffffffffffffffffffffffff1663e942b5166040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260078152602001807f6163636f756e7400000000000000000000000000000000000000000000000000815250602001838103825260048152602001807f42616e6b0000000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b15801561080557600080fd5b505af1158015610819573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff16632ef8ba748d8a036040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018381526020018281038252600b8152602001807f61737365745f76616c756500000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b1580156108c757600080fd5b505af11580156108db573d6000803e3d6000fd5b505050508573ffffffffffffffffffffffffffffffffffffffff1663bf2b70a1868873ffffffffffffffffffffffffffffffffffffffff16637857d7c96040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561096057600080fd5b505af1158015610974573d6000803e3d6000fd5b505050506040513d602081101561098a57600080fd5b81019080805190602001909291905050506040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825260048152602001807f42616e6b000000000000000000000000000000000000000000000000000000008152506020019350505050602060405180830381600087803b158015610a8557600080fd5b505af1158015610a99573d6000803e3d6000fd5b505050506040513d6020811015610aaf57600080fd5b81019080805190602001909291905050509350600184141515610bdc577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb99507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015610b97578082015181840152602081019050610b7c565b50505050905090810190601f168015610bc45780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b8573ffffffffffffffffffffffffffffffffffffffff166313db93466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610c4057600080fd5b505af1158015610c54573d6000803e3d6000fd5b505050506040513d6020811015610c6a57600080fd5b810190808051906020019092919050505092508273ffffffffffffffffffffffffffffffffffffffff1663e942b5168e6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260078152602001807f6163636f756e7400000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610d3d578082015181840152602081019050610d22565b50505050905090810190601f168015610d6a5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610d8a57600080fd5b505af1158015610d9e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff16632ef8ba748d89016040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018381526020018281038252600b8152602001807f61737365745f76616c75650000000000000000000000000000000000000000008152506020019250505060006040","5180830381600087803b158015610e4c57600080fd5b505af1158015610e60573d6000803e3d6000fd5b505050508573ffffffffffffffffffffffffffffffffffffffff1663bf2b70a18e858973ffffffffffffffffffffffffffffffffffffffff16637857d7c96040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610ee657600080fd5b505af1158015610efa573d6000803e3d6000fd5b505050506040513d6020811015610f1057600080fd5b81019080805190602001909291905050506040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825285818151815260200191508051906020019080838360005b83811015610ff0578082015181840152602081019050610fd5565b50505050905090810190601f16801561101d5780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b505050506040513d602081101561106857600080fd5b8101908080519060200190929190505050507f8f6b9fa4d4bf04c7c1c3242d4a5c59ba22525b6761cf89e44becb27c606154bd8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015611122578082015181840152602081019050611107565b50505050905090810190601f16801561114f5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a16111696002611ccc565b91508173ffffffffffffffffffffffffffffffffffffffff166313db93466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156111cf57600080fd5b505af11580156111e3573d6000803e3d6000fd5b505050506040513d60208110156111f957600080fd5b810190808051906020019092919050505090508073ffffffffffffffffffffffffffffffffffffffff1663e942b5168f6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156112cc5780820151818401526020810190506112b1565b50505050905090810190601f1680156112f95780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561131957600080fd5b505af115801561132d573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff1663e942b5166040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260108152602001807f66696e616e6365725f6163636f756e7400000000000000000000000000000000815250602001838103825260048152602001807f42616e6b0000000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b15801561140a57600080fd5b505af115801561141e573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff1663e942b5168e6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260108152602001807f66696e616e6365655f6163636f756e7400000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156114e25780820151818401526020810190506114c7565b50505050905090810190601f16801561150f5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561152f57600080fd5b505af1158015611543573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff16638a42ebe98d6040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001838152602001828103825260068152602001807f616d6f756e74000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b1580156115ef57600080fd5b505af1158015611603573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff166331afac3661162e600054611fa3565b836040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b838110156116cc5780820151818401526020810190506116b1565b50505050905090810190601f1680156116f95780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b505050506040513d602081101561174357600080fd5b81019080805190602001909291905050505060008081548092919060010191905055507f555b1ba9398ece7e615a8f7181cd35129524d625e8fbef36b217a573248fb8218a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b8381101561180e5780820151818401526020810190506117f3565b50505050905090810190601f16801561183b5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a505b505050505050505050509392505050565b6000806000806000806118736000611ccc565b93508373ffffffffffffffffffffffffffffffffffffffff1663e8434e39888673ffffffffffffffffffffffffffffffffffffffff16637857d7c96040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156118f657600080fd5b505af115801561190a573d6000803e3d6000fd5b505050506040513d602081101561192057600080fd5b81019080805190602001909291905050506040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b838110156119ce5780820151818401526020810190506119b3565b50505050905090810190601f1680156119fb5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015611a1b57600080fd5b505af1158015611a2f573d6000803e3d6000fd5b505050506040513d6020811015611a4557600080fd5b81019080805190602001909291905050509250600091508273ffffffffffffffffffffffffffffffffffffffff1663949d225d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015611ac057600080fd5b505af1158015611ad4573d6000803e3d6000fd5b505050506040513d6020811015611aea57600080fd5b810190808051906020019092919050505060001415611b31577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8281915095509550611cc3565b8273ffffffffffffffffffffffffffffffffffffffff1663846719e060006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050506040513d6020811015611bcb57600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663fda69fae6040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f61737365745f76616c7565000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611c8057600080fd5b505af1158015611c94573d6000803e3d6000fd5b505050506040513d6020811015611caa57600080fd5b8101908080519060200190929190505050819150955095505b50505050915091565b600080600080841415611dc35761100191508173ffffffffffffffffffffffffffffffffffffffff1663f23f63c96040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260078152602001807f745f617373657400000000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b505050506040513d6020811015611da857600080fd5b81019080805190602001909291905050509050809250611f9c565b6001841415611eb65761100191508173ffffffffffffffffffffffffffffffffffffffff1663f23f63c96040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260098152602001807f745f726563656970","740000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611e7157600080fd5b505af1158015611e85573d6000803e3d6000fd5b505050506040513d6020811015611e9b57600080fd5b81019080805190602001909291905050509050809250611f9c565b61100191508173ffffffffffffffffffffffffffffffffffffffff1663f23f63c96040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260098152602001807f745f66696e616e63650000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611f5b57600080fd5b505af1158015611f6f573d6000803e3d6000fd5b505050506040513d6020811015611f8557600080fd5b810190808051906020019092919050505090508092505b5050919050565b60606000806060600080861415611ff1576040805190810160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525094506120f1565b8593505b60008414151561201b578280600101935050600a8481151561201357fe5b049350611ff5565b826040519080825280601f01601f19166020018201604052801561204e5781602001602082028038833980820191505090505b5091506001830390505b6000861415156120ed57600a8681151561206e57fe5b066030017f0100000000000000000000000000000000000000000000000000000000000000028282806001900393508151811015156120a957fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a868115156120e557fe5b049550612058565b8194505b505050509190505600a165627a7a723058205b53e586804f7157bcb0ee15cd46361888f04c5b0099f6e79cc7f7ce74000d9a0029"};

    public static final String BINARY = String.join("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {"60806040523480156200001157600080fd5b506200002b62000038640100000000026401000000009004565b60008081905550620001b9565b600061100190508073ffffffffffffffffffffffffffffffffffffffff1663c92a78016040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018060200180602001848103845260098152602001807f745f66696e616e63650000000000000000000000000000000000000000000000815250602001848103835260028152602001807f69640000000000000000000000000000000000000000000000000000000000008152506020018481038252602a8152602001807f66696e616e6365725f6163636f756e742c2066696e616e6365655f6163636f7581526020017f6e742c20616d6f756e74000000000000000000000000000000000000000000008152506040019350505050602060405180830381600087803b1580156200017857600080fd5b505af11580156200018d573d6000803e3d6000fd5b505050506040513d6020811015620001a457600080fd5b81019080805190602001909291905050505050565b61212680620001c96000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806326f89d52146100515780635b325d781461011e575b600080fd5b34801561005d57600080fd5b50610108600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001909291905050506101a2565b6040518082815260200191505060405180910390f35b34801561012a57600080fd5b50610185600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611860565b604051808381526020018281526020019250505060405180910390f35b60008060008060008060008060008060008099506000985060009750600096506102006040805190810160405280600481526020017f42616e6b00000000000000000000000000000000000000000000000000000000815250611860565b809950819a505050600089141515610322577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b838110156102dd5780820151818401526020810190506102c2565b50505050905090810190601f16801561030a5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b61032b8d611860565b809850819a50505060008914151561044d577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe99507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b838110156104085780820151818401526020810190506103ed565b50505050905090810190601f1680156104355780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b8b881015610565577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd99507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015610520578082015181840152602081019050610505565b50505050905090810190601f16801561054d5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b868c8801101561067f577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc99507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b8381101561063a57808201518184015260208101905061061f565b50505050905090810190601f1680156106675780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b6106896000611ccc565b95508573ffffffffffffffffffffffffffffffffffffffff16635887ab246040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156106ef57600080fd5b505af1158015610703573d6000803e3d6000fd5b505050506040513d602081101561071957600080fd5b810190808051906020019092919050505094508473ffffffffffffffffffffffffffffffffffffffff16631a391cb46040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260078152602001807f6163636f756e7400000000000000000000000000000000000000000000000000815250602001838103825260048152602001807f42616e6b0000000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b15801561080557600080fd5b505af1158015610819573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663def426988d8a036040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018381526020018281038252600b8152602001807f61737365745f76616c756500000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b1580156108c757600080fd5b505af11580156108db573d6000803e3d6000fd5b505050508573ffffffffffffffffffffffffffffffffffffffff1663664b37d6868873ffffffffffffffffffffffffffffffffffffffff1663c74f8caf6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561096057600080fd5b505af1158015610974573d6000803e3d6000fd5b505050506040513d602081101561098a57600080fd5b81019080805190602001909291905050506040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825260048152602001807f42616e6b000000000000000000000000000000000000000000000000000000008152506020019350505050602060405180830381600087803b158015610a8557600080fd5b505af1158015610a99573d6000803e3d6000fd5b505050506040513d6020811015610aaf57600080fd5b81019080805190602001909291905050509350600184141515610bdc577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb99507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015610b97578082015181840152602081019050610b7c565b50505050905090810190601f168015610bc45780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a5061184f565b8573ffffffffffffffffffffffffffffffffffffffff16635887ab246040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610c4057600080fd5b505af1158015610c54573d6000803e3d6000fd5b505050506040513d6020811015610c6a57600080fd5b810190808051906020019092919050505092508273ffffffffffffffffffffffffffffffffffffffff16631a391cb48e6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260078152602001807f6163636f756e7400000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610d3d578082015181840152602081019050610d22565b50505050905090810190601f168015610d6a5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610d8a57600080fd5b505af1158015610d9e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663def426988d89016040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018381526020018281038252600b8152602001807f61737365745f76616c75650000000000000000000000000000000000000000008152506020019250505060006040","5180830381600087803b158015610e4c57600080fd5b505af1158015610e60573d6000803e3d6000fd5b505050508573ffffffffffffffffffffffffffffffffffffffff1663664b37d68e858973ffffffffffffffffffffffffffffffffffffffff1663c74f8caf6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610ee657600080fd5b505af1158015610efa573d6000803e3d6000fd5b505050506040513d6020811015610f1057600080fd5b81019080805190602001909291905050506040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825285818151815260200191508051906020019080838360005b83811015610ff0578082015181840152602081019050610fd5565b50505050905090810190601f16801561101d5780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b505050506040513d602081101561106857600080fd5b8101908080519060200190929190505050507f105af2c562df33af7eaa9de5fb0c18d8d30f281a18f95a8f76b44353a322693c8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b83811015611122578082015181840152602081019050611107565b50505050905090810190601f16801561114f5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a16111696002611ccc565b91508173ffffffffffffffffffffffffffffffffffffffff16635887ab246040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156111cf57600080fd5b505af11580156111e3573d6000803e3d6000fd5b505050506040513d60208110156111f957600080fd5b810190808051906020019092919050505090508073ffffffffffffffffffffffffffffffffffffffff16631a391cb48f6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156112cc5780820151818401526020810190506112b1565b50505050905090810190601f1680156112f95780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561131957600080fd5b505af115801561132d573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff16631a391cb46040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260108152602001807f66696e616e6365725f6163636f756e7400000000000000000000000000000000815250602001838103825260048152602001807f42616e6b0000000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b15801561140a57600080fd5b505af115801561141e573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff16631a391cb48e6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260108152602001807f66696e616e6365655f6163636f756e7400000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156114e25780820151818401526020810190506114c7565b50505050905090810190601f16801561150f5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561152f57600080fd5b505af1158015611543573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff1663f2f4ee6d8d6040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001838152602001828103825260068152602001807f616d6f756e74000000000000000000000000000000000000000000000000000081525060200192505050600060405180830381600087803b1580156115ef57600080fd5b505af1158015611603573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16634c6f30c061162e600054611fa3565b836040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b838110156116cc5780820151818401526020810190506116b1565b50505050905090810190601f1680156116f95780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b505050506040513d602081101561174357600080fd5b81019080805190602001909291905050505060008081548092919060010191905055507f124795921f3f60f3220254f809a372363eb9ba973fabfc6679c4c0f272ef515e8a8e8e604051808481526020018060200180602001848152602001838103835260048152602001807f42616e6b00000000000000000000000000000000000000000000000000000000815250602001838103825285818151815260200191508051906020019080838360005b8381101561180e5780820151818401526020810190506117f3565b50505050905090810190601f16801561183b5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1899a505b505050505050505050509392505050565b6000806000806000806118736000611ccc565b93508373ffffffffffffffffffffffffffffffffffffffff1663d8ac5957888673ffffffffffffffffffffffffffffffffffffffff1663c74f8caf6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156118f657600080fd5b505af115801561190a573d6000803e3d6000fd5b505050506040513d602081101561192057600080fd5b81019080805190602001909291905050506040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b838110156119ce5780820151818401526020810190506119b3565b50505050905090810190601f1680156119fb5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015611a1b57600080fd5b505af1158015611a2f573d6000803e3d6000fd5b505050506040513d6020811015611a4557600080fd5b81019080805190602001909291905050509250600091508273ffffffffffffffffffffffffffffffffffffffff1663d3e9af5a6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015611ac057600080fd5b505af1158015611ad4573d6000803e3d6000fd5b505050506040513d6020811015611aea57600080fd5b810190808051906020019092919050505060001415611b31577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8281915095509550611cc3565b8273ffffffffffffffffffffffffffffffffffffffff16633dd2b61460006040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050506040513d6020811015611bcb57600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff16634900862e6040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f61737365745f76616c7565000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611c8057600080fd5b505af1158015611c94573d6000803e3d6000fd5b505050506040513d6020811015611caa57600080fd5b8101908080519060200190929190505050819150955095505b50505050915091565b600080600080841415611dc35761100191508173ffffffffffffffffffffffffffffffffffffffff166359a48b656040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260078152602001807f745f617373657400000000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b505050506040513d6020811015611da857600080fd5b81019080805190602001909291905050509050809250611f9c565b6001841415611eb65761100191508173ffffffffffffffffffffffffffffffffffffffff166359a48b656040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260098152602001807f745f726563656970","740000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611e7157600080fd5b505af1158015611e85573d6000803e3d6000fd5b505050506040513d6020811015611e9b57600080fd5b81019080805190602001909291905050509050809250611f9c565b61100191508173ffffffffffffffffffffffffffffffffffffffff166359a48b656040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260098152602001807f745f66696e616e63650000000000000000000000000000000000000000000000815250602001915050602060405180830381600087803b158015611f5b57600080fd5b505af1158015611f6f573d6000803e3d6000fd5b505050506040513d6020811015611f8557600080fd5b810190808051906020019092919050505090508092505b5050919050565b60606000806060600080861415611ff1576040805190810160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525094506120f1565b8593505b60008414151561201b578280600101935050600a8481151561201357fe5b049350611ff5565b826040519080825280601f01601f19166020018201604052801561204e5781602001602082028038833980820191505090505b5091506001830390505b6000861415156120ed57600a8681151561206e57fe5b066030017f0100000000000000000000000000000000000000000000000000000000000000028282806001900393508151811015156120a957fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a868115156120e557fe5b049550612058565b8194505b505050509190505600a165627a7a723058200f437029a1c050223949d3d3d92d53820961cd4642184272350d919cd043acd30029"};

    public static final String SM_BINARY = String.join("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"to_account\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"financingFromBank\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"account\",\"type\":\"string\"}],\"name\":\"select\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"ret\",\"type\":\"int256\"},{\"indexed\":false,\"name\":\"from_account\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"to_account\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FinancingEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"ret\",\"type\":\"int256\"},{\"indexed\":false,\"name\":\"from_account\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"to_account\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferEvent\",\"type\":\"event\"}]"};

    public static final String ABI = String.join("", ABI_ARRAY);

    public static final String FUNC_FINANCINGFROMBANK = "financingFromBank";

    public static final String FUNC_SELECT = "select";

    public static final Event FINANCINGEVENT_EVENT = new Event("FinancingEvent", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}));
    ;

    public static final Event TRANSFEREVENT_EVENT = new Event("TransferEvent", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}));
    ;

    protected Finance(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public TransactionReceipt financingFromBank(String id, String to_account, BigInteger amount) {
        final Function function = new Function(
                FUNC_FINANCINGFROMBANK, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(to_account), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void financingFromBank(String id, String to_account, BigInteger amount, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_FINANCINGFROMBANK, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(to_account), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount)), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForFinancingFromBank(String id, String to_account, BigInteger amount) {
        final Function function = new Function(
                FUNC_FINANCINGFROMBANK, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(to_account), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple3<String, String, BigInteger> getFinancingFromBankInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_FINANCINGFROMBANK, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple3<String, String, BigInteger>(

                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (BigInteger) results.get(2).getValue()
                );
    }

    public Tuple1<BigInteger> getFinancingFromBankOutput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getOutput();
        final Function function = new Function(FUNC_FINANCINGFROMBANK, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple1<BigInteger>(

                (BigInteger) results.get(0).getValue()
                );
    }

    public Tuple2<BigInteger, BigInteger> select(String account) throws ContractException {
        final Function function = new Function(FUNC_SELECT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(account)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple2<BigInteger, BigInteger>(
                (BigInteger) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue());
    }

    public List<FinancingEventEventResponse> getFinancingEventEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(FINANCINGEVENT_EVENT, transactionReceipt);
        ArrayList<FinancingEventEventResponse> responses = new ArrayList<FinancingEventEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            FinancingEventEventResponse typedResponse = new FinancingEventEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.ret = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.from_account = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.to_account = (String) eventValues.getNonIndexedValues().get(2).getValue();
            typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeFinancingEventEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(FINANCINGEVENT_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeFinancingEventEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(FINANCINGEVENT_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<TransferEventEventResponse> getTransferEventEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFEREVENT_EVENT, transactionReceipt);
        ArrayList<TransferEventEventResponse> responses = new ArrayList<TransferEventEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            TransferEventEventResponse typedResponse = new TransferEventEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.ret = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.from_account = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.to_account = (String) eventValues.getNonIndexedValues().get(2).getValue();
            typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeTransferEventEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(TRANSFEREVENT_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeTransferEventEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(TRANSFEREVENT_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public static Finance load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new Finance(contractAddress, client, credential);
    }

    public static Finance deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(Finance.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }

    public static class FinancingEventEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger ret;

        public String from_account;

        public String to_account;

        public BigInteger amount;
    }

    public static class TransferEventEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger ret;

        public String from_account;

        public String to_account;

        public BigInteger amount;
    }
}
